Skip to content

PHPLIB-1440: Sync range v2 spec tests to latest version #1373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Sep 4, 2024

PHPLIB-1440

This syncs spec tests to mongodb/specifications@f5a1899

@alcaeus alcaeus requested a review from jmikola September 4, 2024 08:23
@alcaeus alcaeus requested a review from a team as a code owner September 4, 2024 08:23
Comment on lines +133 to +135
},
"result": {
"ok": 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed a similar assertion in fle2v2-Rangev2-Compact as that test failed due to a type mismatch:

[2024/09/04 10:33:57.215] Failed asserting that two strings are equal.
[2024/09/04 10:33:57.215] --- Expected
[2024/09/04 10:33:57.215] +++ Actual
[2024/09/04 10:33:57.215] @@ @@
[2024/09/04 10:33:57.215] -'{ "ok" : 1 }'
[2024/09/04 10:33:57.215] +'{ "ok" : 1.0 }'
[2024/09/04 10:33:57.215] /data/mci/f802858d094039b002289e9b38f42a7b/src/tests/TestCase.php:116
[2024/09/04 10:33:57.215] /data/mci/f802858d094039b002289e9b38f42a7b/src/tests/SpecTests/ResultExpectation.php:252
[2024/09/04 10:33:57.215] /data/mci/f802858d094039b002289e9b38f42a7b/src/tests/SpecTests/Operation.php:205
[2024/09/04 10:33:57.215] /data/mci/f802858d094039b002289e9b38f42a7b/src/tests/SpecTests/ClientSideEncryptionSpecTest.php:210

Doesn't the absence of a result field imply that the command should at least succeed, but no assertions on the result should be made? If so, then this result expectation isn't really necessary, as the command failing should trip up test runners regardless. Note that this is the legacy CSFLE test runner, so its behaviour may be a little more undefined than the unified test runner.

If this expectation is not necessary, I'd update the spec tests; if it is we'd have to update our matcher to ignore the type difference. What do you think @jmikola?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where the ambiguity is coming from here (I know mongod and mongos used to differ in what they used for ok), but I assume PHPLIB's legacy test runner isn't handling flexible numeric comparisons as we mandate in the unified runner.

The runCommand spec doesn't talk about throwing in the event of an unsuccessful response (i.e. ok is not 1 or 1.0), but I'd hope we can trust the legacy test runner to throw in the event of an unsuccessful command. Would be good to run this by @kevinAlbs if you wanted to remove the result expectation entirely.

Otherwise, we can consider adding flexible numeric comparisons to PHPLIB's legacy runner.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the absence of a result field imply that the command should at least succeed

mongodb/specifications#1605 noted:

Adding result: { ok: 1 } to the operation is to ensure test runners check the operation succeeded. The test format does not require checking the operation succeeded if result is not present.

As a result, a bug in libmongocrypt (MONGOCRYPT-699) had gone unnoticed (at least in libmongoc's legacy test runner).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying! I'll update our legacy test runner accordingly.

@alcaeus alcaeus changed the base branch from master to v1.20 September 4, 2024 12:53
@alcaeus alcaeus force-pushed the phplib-1440-range-ga branch from 8146822 to 88bf036 Compare September 6, 2024 08:27
@alcaeus alcaeus requested a review from GromNaN September 6, 2024 08:34
@alcaeus alcaeus enabled auto-merge (squash) September 6, 2024 08:53
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Document::fromPHP($normalizedExpectedDocument)->toRelaxedExtendedJSON(),
Document::fromPHP($normalizedActualDocument)->toRelaxedExtendedJSON(),
);
(new DocumentsMatchConstraint($expectedDocument, true, true))->evaluate($actualDocument);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alcaeus alcaeus merged commit 801f4d2 into mongodb:v1.20 Sep 6, 2024
36 checks passed
@alcaeus alcaeus deleted the phplib-1440-range-ga branch September 6, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants